import * as api from '../api/api'
import {
  formateTime
} from '../util/date';
export function list(params) {
  return api.post('/goods-activity/list', params).then(data => {
    data = data || {};
    data.rows && data.rows.forEach(item => {
      item.create_time = formateTime(item.create_time);
      item.modify_time = formateTime(item.modify_time);
      item.start_time = formateTime(item.start_time);
      item.end_time = formateTime(item.end_time);
    });
    return data;
  })
}
export function addGoods2Activity(goodsSkuId, activityId) {
  return api.post('/goods-activity/add-goods-to-activity', {
    goodsSkuId,
    activityId
  })
}
export function removeGoodsFromActivity(goodsSkuId, activityId) {
  return api.post('/goods-activity/remove-goods-from-activity', {
    goodsSkuId,
    activityId
  })
}
export function create(params) {
  return api.post('/goods-activity/create', params)
}
export function modify(params) {
  return api.post('/goods-activity/update', params)
}

export function remove(id) {
  return api.post('/goods-activity/delete', {
    id
  })
}

export function setOnline(id) {
  return api.post('/goods-activity/set-online', {
    id
  })
}

export function setOffline(id) {
  return api.post('/goods-activity/set-offline', {
    id
  })
}
export function setActivityGoodsSkuPrice({
  activityId,
  goodsId,
  price
}) {
  return api.post('/goods-activity/set-activity-goods-sku-member-price', {
    activityId,
    goodsId,
    price
  })
}

export function setActivityGoodsSkuMemberPrice({
  activityId,
  goodsId,
  price
}) {
  return api.post('/goods-activity/set-activity-goods-sku-member-price', {
    activityId,
    goodsId,
    price
  })
}
